package com.itheima.d1_algorithm;

import java.util.Arrays;
import java.util.concurrent.ForkJoinPool;

public class Test2 {
    public static void main(String[] args) {
        //选择排序
        int[] arr = {1,5,3,6,2,9};

        for (int i = 0; i < arr.length-1; i++) {//外层循环控制轮数
            int minIndex = i;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[minIndex] >arr[j]){
                    minIndex =j;
                }
            }

            if(i != minIndex){
                int temp =arr[i];
                arr[i] =arr[minIndex];
                arr[minIndex] =temp;
            }
        }
        System.out.println("选择排序升序为:"+ Arrays.toString(arr));
    }
}
